#仪器仪表盘读数识别
import requests 
# client_id 为官网获取的AK， client_secret 为官网获取的SK
host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id={}&client_secret={}'
client_id = "O1APUGdvwyCwZLV1sHIKZEEa"
client_secret = "N6jOswPTuPYFRLwpSLZufWBHeYdG9WpE"
response = requests.get(host.format(client_id, client_secret))
if response:
    print(response.json())

import requests
import base64
#仪器仪表盘读数识别
request_url = "https://aip.baidubce.com/rest/2.0/ocr/v1/meter"
f = open('C:/Users/ycqq/Desktop/www.jpg','rb')
img = base64.b64encode(f.read())

params = {"image":img}
access_token = '24.3b3d42956745e73461d05e63a9dc86e3.2592000.1613533838.282335-23555565'
request_url = request_url + "?access_token=" + access_token
headers = {'content-type': 'application/x-www-form-urlencoded'}
r=response = requests.post(request_url, data=params, headers=headers)
r.status_code
result=r.json()
result


#人脸搜索
 import requests 
# client_id 为官网获取的AK， client_secret 为官网获取的SK
host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id={}&client_secret={}'
client_id = "Yp3XQomq8wZovpPW1RWE9DdB"
client_secret = "ttCaWla7Gkjby2EKsMRcXt0xcX4DXI5V"
response = requests.get(host.format(client_id, client_secret))
if response:
    print(response.json())

request_url = "https://aip.baidubce.com/rest/2.0/face/v3/search"
data = {"https://tx-free-imgs.acfun.cn/OQJqrNDHYn-MryAJf-7vMJve-JBFvym-EJzUnu.jpg",
       "image_type":"URL",
       "FACE_TOKEN":"FACE_TOKEN",
       "group_id":"group_repeat",
       "user_id":"sure",
       "user_info":"abc",
       "quality_control":"LOW",
        "liveness_control":"NORMAL",
       }
access_token = '[24.e7fea1434e9d3c2ee1e6a18c7253cefd.2592000.1613542950.282335-23556169]'
request_url = request_url + "?access_token=" + access_token
headers = {'content-type': 'application/json'}
response = requests.post(request_url, params=data, headers=headers)
if response:
    print (response.json())


#数字识别
import requests 
# client_id 为官网获取的AK， client_secret 为官网获取的SK
host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id={}&client_secret={}'
client_id = "O1APUGdvwyCwZLV1sHIKZEEa"
client_secret = "N6jOswPTuPYFRLwpSLZufWBHeYdG9WpE"
response = requests.get(host.format(client_id, client_secret))
if response:
    print(response.json()) 

import requests
import base64
request_url = "https://aip.baidubce.com/rest/2.0/ocr/v1/numbers"
# 二进制方式打开图片文件
f = open('C:/Users/ycqq/Desktop/222.png','rb')
img = base64.b64encode(f.read())

params = {"image":img}
access_token = '24.da200761eb7f527411641bc6af7cc456.2592000.1613543966.282335-23555565'
request_url = request_url + "?access_token=" + access_token
headers = {'content-type': 'application/x-www-form-urlencoded'}
response = requests.post(request_url, data=params, headers=headers)
if response:
    print (response.json())    